GError **error)
{
gboolean ret = FALSE;
- int fd = -1;
+ glnx_fd_close int fd = -1;
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
ret = TRUE;
out:
- if (fd != -1)
- (void) close (fd);
return ret;
}
{
gboolean ret = FALSE;
gboolean did_exist = FALSE;
- int destination_dfd = -1;
+ glnx_fd_close int destination_dfd = -1;
int res;
g_autoptr(GVariant) xattrs = NULL;
g_autoptr(GFileEnumerator) dir_enum = NULL;
ret = TRUE;
out:
- if (destination_dfd != -1)
- (void) close (destination_dfd);
return ret;
}
{
gboolean ret = FALSE;
char loose_path_buf[_OSTREE_LOOSE_PATH_MAX];
- int fd = -1;
+ glnx_fd_close int fd = -1;
g_autoptr(GInputStream) ret_stream = NULL;
g_autoptr(GVariant) ret_variant = NULL;
mfile = g_mapped_file_new_from_fd (fd, FALSE, error);
if (!mfile)
goto out;
- (void) close (fd); /* Ignore errors, we have it mapped */
- fd = -1;
ret_variant = g_variant_new_from_data (ostree_metadata_variant_type (objtype),
g_mapped_file_get_contents (mfile),
g_mapped_file_get_length (mfile),
ot_transfer_out_value (out_variant, &ret_variant);
ot_transfer_out_value (out_stream, &ret_stream);
out:
- if (fd != -1)
- (void) close (fd);
return ret;
}
GError **error)
{
gboolean ret = FALSE;
- int src_dfd = -1;
- int dest_dfd = -1;
+ glnx_fd_close int src_dfd = -1;
+ glnx_fd_close int dest_dfd = -1;
DIR *srcd = NULL;
struct dirent *dent;
/* Note the srcd owns src_dfd */
src_dfd = -1;
}
- if (src_dfd != -1)
- (void) close (src_dfd);
- if (dest_dfd != -1)
- (void) close (dest_dfd);
return ret;
}
GError **error)
{
gboolean ret = FALSE;
- int src_dfd = -1;
- int target_dfd = -1;
+ glnx_fd_close int src_dfd = -1;
+ glnx_fd_close int target_dfd = -1;
g_assert (path != NULL);
g_assert (*path != '/' && *path != '\0');
target_dfd = -1;
}
out:
- if (src_dfd != -1)
- (void) close (src_dfd);
- if (target_dfd != -1)
- (void) close (target_dfd);
return ret;
}
gboolean ret = FALSE;
struct stat modified_stbuf;
struct stat new_stbuf;
- int dest_parent_dfd = -1;
+ glnx_fd_close int dest_parent_dfd = -1;
if (fstatat (modified_etc_fd, path, &modified_stbuf, AT_SYMLINK_NOFOLLOW) < 0)
{
ret = TRUE;
out:
- if (dest_parent_dfd != -1)
- (void) close (dest_parent_dfd);
return ret;
}
g_autoptr(GPtrArray) removed = NULL;
g_autoptr(GPtrArray) added = NULL;
guint i;
- int orig_etc_fd = -1;
- int modified_etc_fd = -1;
- int new_etc_fd = -1;
+ glnx_fd_close int orig_etc_fd = -1;
+ glnx_fd_close int modified_etc_fd = -1;
+ glnx_fd_close int new_etc_fd = -1;
modified = g_ptr_array_new_with_free_func ((GDestroyNotify) ostree_diff_item_unref);
removed = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
ret = TRUE;
out:
- if (orig_etc_fd != -1)
- (void) close (orig_etc_fd);
- if (modified_etc_fd != -1)
- (void) close (modified_etc_fd);
- if (new_etc_fd != -1)
- (void) close (new_etc_fd);
return ret;
}
GError **error)
{
gboolean ret = FALSE;
- int parent_dfd;
+ glnx_fd_close int parent_dfd = -1;
const char *target_basename = glnx_basename (gs_file_get_path_cached (path));
g_autoptr(GFile) parent = NULL;
ret = TRUE;
out:
- if (parent_dfd != -1)
- (void) close (parent_dfd);
return ret;
}
GError **error)
{
gboolean ret = FALSE;
- int dfd = -1;
+ glnx_fd_close int dfd = -1;
if (!glnx_opendirat (AT_FDCWD, gs_file_get_path_cached (dir), TRUE,
&dfd, error))
ret = TRUE;
out:
- if (dfd != -1)
- (void) close (dfd);
return ret;
}
GError **error)
{
gboolean ret = FALSE;
- int parentfd = -1;
+ glnx_fd_close int parentfd = -1;
const char *basename = glnx_basename (gs_file_get_path_cached (dir));
g_autoptr(GFile) parent = g_file_get_parent (dir);
ret = TRUE;
out:
- if (parentfd != -1)
- (void) close (parentfd);
return ret;
}